home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / util / sys / SerPrefs.lha / SerPrefs / Developers / modules / prefs / serial.e next >
Text File  |  1997-11-25  |  7KB  |  203 lines

  1. /* $VER: serial.e 42.2 (4.10.1997) #ESOURCE © Msi Software
  2. **
  3. ** File format for new (v1) serial preferences
  4. **
  5. ** Original (v38) structure was 33 in size, the new is 34 in size.
  6. **
  7. ** (C) Copyright 1997 Msi Software.
  8. ** All Rights Reserved
  9. */
  10.  
  11. OPT MODULE
  12. OPT EXPORT
  13. OPT PREPROCESS      /* Make shure you use the same option in your source */
  14.  
  15. CONST ID_SERL=$5345524C, /* Serial settings ID */
  16.       ID_SERN=$5345524E  /* Serial name ID */
  17.  
  18. OBJECT serialprefs
  19.   reserved[3]:ARRAY OF LONG  /* System Reserved */
  20.   unit0map:LONG              /* default unit */
  21.   baudrate:LONG              /* baud to be used */
  22.   inputbuffer:LONG           /* buffer size to be used (in bytes) */
  23.   outputbuffer:LONG          /* buffer size to be used (in bytes) */
  24.   inputhandshake:CHAR        /* see handshake constants */
  25.   outputhandshake:CHAR       /* see handshake constants */
  26.   parity:CHAR                /* see parity constants */
  27.   bitsperchar:CHAR           /* data bits */
  28.   stopbits:CHAR              /* stop bits */
  29.                              /* The original "C=" object ends here! */
  30.   sharedmode:CHAR            /* see shared constants */
  31. ENDOBJECT /* SIZE 34, original was 33 */
  32.  
  33. /* "sername" Full pathname of device, (0 terminated) */
  34. /* Stored in a separate IFF "SERN" CHUNK after the SERL chunk */
  35.  
  36. CONST PARITY_NONE=0,
  37.       PARITY_EVEN=1,
  38.       PARITY_ODD=2,
  39.       PARITY_MARK=3,
  40.       PARITY_SPACE=4,
  41.       HSHAKE_XON=0,
  42.       HSHAKE_RTS=1,
  43.       HSHAKE_NONE=2,
  44.                       /* End of original "C=" constants! */
  45.       SHARED_NONE=0,
  46.       SHARED_ON=1
  47.  
  48. /* some nice strings to be used with AmigaE preprocessing */
  49. #define DEFSERNAME 'DEVS:serial.device'
  50. #define DEFSERENV 'ENV:Sys/serial.prefs'
  51. #define DEFSERENVARC 'ENVARC:Sys/serial.prefs'
  52. #define DEFSERPREFICON 'ENV:Sys/def_prefs'
  53. #define DEFSERPREFTOOL 'Sys:Prefs/Serial'
  54.  
  55. /* serial.prefs versions
  56.    SerPrefs uses the type entry in the PRHD chunk (prefheader)
  57.    to let you know that the prefs are different.
  58.    (INCLUDES:prefs/prefhdr.h)
  59.    The original serial.prefs keep that value 0,
  60.    and serial.prefs v42.x keep this value 1.
  61.    When the next serial.prefs is defined it will
  62.    have value 2 or something like that.
  63.    So check the type in the PRHD chunk,
  64.    since this is much better and safer than checking the size
  65.    of the SERL chunk :-)
  66.    If you find i.e 0 as the type in PRHD,
  67.    then DO NOT try to use any data after the stop bit,
  68.    since this most likely is an old serial.prefs.
  69.    This way old programs can use new prefs without problems,
  70.    (the old Serial programs will ignore any extra data).
  71.    And new programs is able to use old prefs,
  72.    with no need for the user to convert the prefs.
  73.  
  74.    A nice way to read the serial.prefs is:
  75.    1. get prefsheader.version
  76.    2. get prefsheader.type
  77.    3. get prefsheader.flags
  78.    4. if version is not 0 then report to user and abort
  79.    5. currently just ignore the flags
  80.    6. check SERL chunk lenght (do not use lenght for version/type checking)
  81.    7. process first part (v0)
  82.    8. if type was 1 process second part (v1)
  83.    9. (when v2 etc is used you would process it here and so on)
  84.   10. get SERN and process filename if any (perhaps get device version)
  85.  
  86.    To avoid problems, always check that the lenght is "larger than 32",
  87.    do not check if it is 34 or 33 since even though it is 33
  88.    the bug cause it to become 34.
  89.    For v1 you should check the SERL lenght if it is larger than 34 or not,
  90.    if a v1 serial.prefs SERL chunk is less than 34, it is corrupt.
  91.    Doing this allow us to use the same code for v0
  92.    for v1 and v2 prefs, instead of separate v0,v1 ad v2 routines.
  93.    SerPrefs v2.1 and later use this method,
  94.    resulting in much less code needed :-)
  95.  
  96.    If you wonder why I used prefheader.type instead of prefheader.version,
  97.    it is because when using prefheader.version,
  98.    IPrefs complain about being unable to read the prefs,
  99.    and since serial.prefs has not really changed,
  100.    but rather been extended this is silly since serial.prefs
  101.    no longer is backwards compatible.
  102.    But since there is no revision to use I had to use type instead,
  103.    after all v1 is a different prefs type than v0 :-)
  104.    So by using type IPrefs is able to read the prefs as v0 prefs,
  105.    thus baud etc is used correctly (at least they should).
  106. */
  107.  
  108. /* sharedmode
  109.    Due to a bug in the C= serial.prefs,
  110.    the SERL chunk pad is counted into the SERL chunk lenght.
  111.    To take advantage of this I used this "hidden" byte to
  112.    toggle sharedmode, please note that neither IPrefs or original Serial
  113.    is aware of this and will just ignore it (thinking it's a pad :-)
  114.    Since the IFF specs say a pad should always be zero,
  115.    we can count on it being correct (not corrupted by Serial prefs utils).
  116.    But since it is counted as a part of the chunk,
  117.    according to the IFF specs it is not a pad :-)
  118.    So we can count on the IFF system to not mess with it either,
  119.    so the result is a unused byte everyone ignores :-)
  120.    I decided the first best thing to add to serial.prefs was Shared Mode,
  121.    and what better place to start than the unused byte?
  122. */
  123.  
  124. /* bitsperchar
  125.    Common "Data Bits" (Bits Per Char):
  126.    5, 6, 7, 8.
  127.    8 is most used, and also the default value.
  128.  
  129.    Additional bits (for future use):
  130.    16, 32.
  131.    These are not used (hardly any hardware support >8 bits,
  132.    but to avoid updating of software,
  133.    these should be supported in preparation of new serial hardware.
  134. */
  135.  
  136. /* stopbits
  137.    Common "Stop Bits":
  138.    0, 1, 2.
  139.    1 is most used, and also the default.
  140. */
  141.  
  142. /* inputbuffer/outputbuffer
  143.    No real limits, can be up to the maximum 32bit value.
  144.    Or down to 64 bytes, the C= docs etc,
  145.    advise this value to be a multiple of 64.
  146.    Advised default is 4096 bytes, advised minimum is 512 bytes.
  147.    For simplicity use x*2, x/2 based values.
  148.    Like 512, 1024, 2048, 4096 etc, so the user don't have to
  149.    flip thru a bunch of numbers forever, or have to type it :-)
  150.    It's easier to keep the value a multiple of 64 bytes also.
  151. */
  152.  
  153. /* baudrate
  154.    No common or advised, this vary alot on modem/hardware/connection etc.
  155.    Can be odd/even, but using well know rates are HIGHLY ADVISED.
  156.    This to avoid confusing users as well as software/hardware :-)
  157.  
  158.    Here is a list of rates (as used in Msi Software's SerPrefs):
  159.  
  160.         75
  161.        110
  162.        150
  163.        300
  164.        600
  165.       1200
  166.       2400
  167.       4800
  168.       7200
  169.       9600 /* fax rate, default (old) */
  170.      14400
  171.      16800
  172.      19200 /* 14.4 rate, fax rate, common default */
  173.      21600
  174.      24000
  175.      26400
  176.      28800
  177.      31200
  178.      31250 /* MIDI rate, max rate on older software/Amiga */
  179.      33600
  180.      38400 /* 28.8/33.6 rate, advised default due to many 28.8 modems */
  181.      57600 /* Max (reliable) internal serial, can be used as 33.6 rate */
  182.      64000
  183.      62400
  184.      64800
  185.      65535
  186.      65536
  187.      76800
  188.     115200 /* Squirrel Surf (SCSI w/serial for A1200) can go this high */
  189.     230400
  190.     345600
  191.     460800
  192.     576000
  193.     614400
  194.     691200
  195.     806400
  196.     921600 (please note that the SerPrefs program may support even more)
  197. */
  198.  
  199. /* Roger Hågensen <emsai@online.no>
  200.    Msi Software - 5th July 1997
  201.    http://www.sn.no/~msi/index.htm
  202. */
  203.